/**
 * www.yiji.com Inc.
 * Copyright (c) 2011 All Rights Reserved.
 */
package com.zqxq.common.constant;

import com.zqxq.common.enums.BeikeResultEnum;
import org.apache.commons.lang3.StringUtils;

public class BeikeBaseResult extends ResultBase {
	
	/** Comment for <code>serialVersionUID</code> */
	private static final long serialVersionUID = 5156892170604621621L;
	/** 返回结果码 */
	BeikeResultEnum beikeResultEnum = BeikeResultEnum.UN_KNOWN_EXCEPTION;

	private String message = "";
	

	public boolean isExecuted() {
		
		return BeikeResultEnum.EXECUTE_SUCCESS == beikeResultEnum ? true : false;
	}


	public String getMessage() {
		return this.message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public BeikeResultEnum getBeikeResultEnum() {
		return beikeResultEnum;
	}
	
	public void setBeikeResultEnum(BeikeResultEnum beikeResultEnum) {
		this.beikeResultEnum = beikeResultEnum;
		if (this.beikeResultEnum != null) {
			if (StringUtils.isEmpty(this.getResultMessage())) {
				this.setResultMessage(this.beikeResultEnum.getMessage());
			}
			
		}
	}
	
	@Override
	public void setSuccess(boolean success) {
		super.setSuccess(success);
		if (success) {
			beikeResultEnum = BeikeResultEnum.EXECUTE_SUCCESS;
		}
	}

	@Override
	public String toString() {
		final StringBuffer sb = new StringBuffer("BeikeBaseResult{");
		sb.append("beikeResultEnum=").append(beikeResultEnum);
		sb.append('}');
		return sb.toString();
	}
}
